# -*- codeing = utf-8 -*-
# @Time : 2021/7/13 17:57
# @Author : xiaow
# @File : mysqldao.py
# @Software : PyCharm
import time

import MySQLdb  # 需要导入的库


def insert(db='robot', tbname='videos', name='', videopath='', imgspath=''):  # 实现的按列表导入数据库
    db = MySQLdb.connect("127.0.0.1", "root", "123456", db, charset='utf8')
    cursor = db.cursor()
    sql = '''
        insert into %s values(0,'%s','%s','%s')
        ''' % (tbname, name, videopath, imgspath)
    cursor.execute(sql)
    db.commit()


# def getAll(db, tbname):
#     db = MySQLdb.connect("106.14.252.11", "root", "123456", db, charset='utf8')
#     cursor = db.cursor()
#     sql = '''
#     select * from {}
#     '''.format(tbname)
#     cursor.execute(sql)
#     results = cursor.fetchall()
#     return results

# def getAllLocal(db, tbname):
#     db = MySQLdb.connect("localhost", "root", "123456", db, charset='utf8')
#     cursor = db.cursor()
#     sql = '''
#     select * from {}
#     '''.format(tbname)
#     cursor.execute(sql)
#     results = cursor.fetchall()
#     return results
#
#
# def list(db, tbname,page):
#     db = MySQLdb.connect("106.14.252.11", "root", "123456", db, charset='utf8')
#     cursor = db.cursor()
#     sql = '''
#     select * from {} limit {},10
#     '''.format(tbname,page*10)
#     cursor.execute(sql)
#     results = cursor.fetchall()
#     return results


if __name__ == '__main__':
    insert("robot","videos","1号管道","xw");

